import axios from '@/utils/request';

/**
 * 一级分类
 * @param params 查询条件
 */
export async function list(params) {
 
  const res = await axios.get('/consume.Platform/index', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function add(data) {
  const res = await axios.post('/consume.Platform/add', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 修改
 * @param data 机构信息
 */
export async function update(data) {
  const res = await axios.post('/consume.Platform/edit', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}





/**
 * 排序
 * @param params nid oid 两个排序的id
 */
 export async function modify(data) {
  const res = await axios.post('/consume.Platform/modify', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除
 * @param id id
 */
export async function remove(id) {
  const res = await axios.get('/consume.Platform/delete?id=' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}




export async function save(data) {
  const res = await axios.post('/consume.Platform/save', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}



/**
 * 查询用户列表
 * @param params 查询条件
 */
 export async function query(params) {

  const res = await axios.get('/consume.Platform/query',{
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 查询用户列表
 * @param params 查询条件
 */
export async function uploadConfigQuery(params) {

  const res = await axios.get('/consume.Platform/uploadConfigQuery',{
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function uploadConfigSave(data) {
  const res = await axios.post('/consume.Platform/uploadConfigSave', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}


export async function messageConfigQuery(params) {

  const res = await axios.get('/consume.Platform/messageConfigQuery',{
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function messageConfigSave(data) {
  const res = await axios.post('/consume.Platform/messageConfigSave', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}


export async function resetPassword(id) {
  const res = await axios.post('/consume.Platform/resetPassword?id=' + id);
  if (res.data.code === 0) {
      return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
